<?php
declare (strict_types=1);

namespace app\api\validate;

use think\Validate;

class TradeOfflineOrder extends Validate
{
    protected $rule = [
        "amount" => "require|gt:0|checkInt",
        "pay_password" => "require",
        "method" => "require",
        "images" => "require",
        "content" => "require",
        "appeal_img" => "require"
    ];

    protected $message = [
        'amount.require' => '请填写交易数量',
        'amount.gt' => '交易数量有误',
        'amount.checkInt' => '交易数量必须为整数',
        'pay_password.require' => '请填写支付密码',
        'method.require' => '请选择支付方式',
        'images.require' => '请上传打款凭证',
        'content.require' => '请填写申诉内容',
        'appeal_img.require' => '请上传申诉图片'
    ];

    protected $scene = [
        'add' => ['amount', 'pay_password'],
        'payment' => ['method', 'images'],
        'appeal' => ['content', 'appeal_img']
    ];

    protected function checkInt($value, $rule, $data = []): bool
    {
        return (string)(int)$value === $value;
    }
}